<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.staticfile.org/jquery/3.6.0/jquery.min.js" type="text/javascript"></script>
</head>
<body>
    <button id="get">GET请求</button>
    <button id="post">POST请求</button>
</body>
<script>

    $(function(){
        $("#get").on("click",function(){
        $.ajax({
            url:"http://127.0.0.1:8081/api/get",
            type:"get",
            data:{
                name:'suliang',
                age:21
            },
            success:function(res){
                console.log(res);
            }
        })
    })
    $("#post").on("click",function(){
        $.ajax({
            url:"http://127.0.0.1:8081/api/post",
            type:"post",
            data:{
                name:'苏凉',
                age:21
            },
            success:function(res){
                console.log(res);
            }
        })
    })
    })
    
</script>
</html>